In a network device, it is often useful to measure performance metrics such as internal packet latency. Such metrics are useful for detection of faults and anomalies in the network device and/or in a communication network.
To measure internal latency, a network device records a time at which a packet is received (receipt time) by the network device, and also records a time at which the packet is transmitted (transmit time) by the network device. The network device compares the transmit time with the receipt time to calculate a latency measurement for the packet. The network device uses latency measurements for multiple packets to calculate latency statistics. For example, a network device may compute respective latency statistics for different ingress port, egress port pairs.